import { ref } from 'vue'
import { defineStore } from 'pinia'
import {getAbout} from '@/api/about'
import type {aboutData} from '@/type/store'
import type {Ref} from 'vue'

export const useAboutStore = defineStore('about', () => {
  const aboutStateRef:Ref<{
    loading: boolean,
    data: string | null
  }> = ref({
    loading: false,
    data: null
  })
  async function fetchData() {
    if (aboutStateRef.value.data) return;
    aboutStateRef.value.loading = true;
    aboutStateRef.value.data = await getAbout() as unknown as string;
    aboutStateRef.value.loading = false;
  }

  return { aboutStateRef, fetchData }
})
